"""
这是初始化 driver 的类 , 其他类继承该类 , 就获得了 setup 和 teardown 方法 .

那么我们可以在 setup 方法中 , 获取参数 , 来控制打开哪个浏览器 .

"""
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.wait import WebDriverWait


class TestBase:

    def setup(self):
        options = Options()
        # 处理SSL证书错误问题
        options.add_argument('--ignore-certificate-errors')
        options.add_argument('--ignore-ssl-errors')
        # 忽略无用的日志
        options.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])

        # env = os.getenv('browser')
        # if not env:
        #     self.driver = webdriver.Chrome(options=options)
        # if env == 'firefox':
        #     self.driver = webdriver.Chrome(options=options)
        # elif env == 'edge':
        #     self.driver = webdriver.Edge(options=options)

        self.driver = webdriver.Chrome(options=options)
        self.driver.maximize_window()
        self.driver.implicitly_wait(2)
        self.wait = WebDriverWait(self.driver, 2)

    def teardown(self):
        sleep(10.8)
        self.driver.close()
        sleep(0.8)
        self.driver.quit()

    @pytest.mark.skip()
    def test_oo0(self):
        pass

    @staticmethod
    def sleep(seconds):
        sleep(seconds)


if __name__ == '__main__':
    pytest.main(['-vs'])
